package com.tpfinal.agenda.view.renderers;

import com.tpfinal.agenda.model.Company;

class FilterCompanies extends Filter {

	public FilterCompanies(ContactsTableModel model) {
		super(model);
	}

	@Override
	void render(String stringFilter) {
		for (ContactViewAdapter viewAdapter : model.getContactsListView()) {
			viewAdapter.setVisible(viewAdapter.getAdaptee() instanceof Company
					&& viewAdapter.getAdaptee().getName().toLowerCase()
							.contains(stringFilter.toLowerCase()));
		}

		showColumn(ContactsTableModel.COLUMN_IDX_TELEFONO_MOVIL, false);
		showColumn(ContactsTableModel.COLUMN_IDX_FECHA_NACIMIENTO, false);
		showColumn(ContactsTableModel.COLUMN_IDX_WEB, true);
		showColumn(ContactsTableModel.COLUMN_IDX_RUBROS, true);

		this.stringFilter = stringFilter;
		model.refresh();

	}

}
